from configparser import ConfigParser
import os

cfg_file = f'./cfg/config.ini'
if os.path.exists(cfg_file):
    print(f"配置文件{cfg_file}不存在")
config = ConfigParser()
config.read(cfg_file)

log_path = config['default'].get('log_path')

apcp_path = config['data info']['apcp_path']
radar_path = config['data info']['radar_path']
station_grid_path = config['data info']['station_grid_path']

datasets_root = config['data info']['datasets_root']
input_path = os.path.join(datasets_root, "input")
label_path = os.path.join(datasets_root, "labels_1")
txt_path = os.path.join(datasets_root, "txtsets")
out_path = os.path.join(datasets_root, "revised")
if not os.path.isdir(out_path):
    os.mkdir(out_path)

weight_root = config['data info']['weight_root']

xdim, ydim, reso = config['data info'].get('data_info').strip().split(',')

device = config.get('model info', 'device')

initTrain = config.getboolean('model info', 'init_train')

leaning_rate = config.getfloat('model info', 'leaning_rate')

weight_decay = config.getfloat('model info', 'weight_decay')

gpu_ids = config['model info'].get('device_ids')
if gpu_ids is None:
    device_ids = [0]
else:
    device_ids = [int(idx.strip()) for idx in gpu_ids.split(',')]

batch_size = config.getint('model info', 'batch_size')

core_count = config.getint('model info', 'core_count')

thread_count = config.getint('model info', 'thread_count')

maxepoch = config.getint('model info', 'maxepoch')

model_date = config.get('model info', 'model date')
